SIZE=8
board=[[0 for x in range(0,SIZE)] for y in range(0,SIZE)]
walk=[(2,1),(-1,2),(1,2),(-2,1),(-2,-1),(1,-2),(-1,-2),(2,-1)]
def horse_walk(pos,remote,board):
#    global board
    x=pos[0]
    y=pos[1]
    board[x][y]=1
    for i in walk:
        x+=i[0]
        y+=i[1]
        if not ((x>=SIZE or x<0) or (y>=SIZE or y<0)):
            if board[x][y]==0:
                remote=horse_walk((x,y),remote+[(x,y)],board)
        if board==[[1 for r in range(0,SIZE)] for c in range(0,SIZE)]:
            return remote
        x=pos[0]
        y=pos[1]
    remote.pop()
    board[x][y]=0
    return remote
def mark(arr,board):
    for i in range(0,len(arr)):
        board[arr[i][0]][arr[i][1]]=i+1
    return board

for i in mark(horse_walk((4,4),[(4,4)],board),board):
    print(i)